// Appendix Table


use "Data_ImportantProvisions_240423.dta", clear


foreach question in "func_democ" "new_democ" "divided_democ"{
	preserve
	keep `question'*_num cat1 lab
	egen mean_`question' = rowmean(`question'_*_num)
	replace mean_`question' = round(mean_`question', 0.01)
	egen median_`question' = rowmedian(`question'_*_num)
	replace median_`question' = round(median_`question', 0.01)
	egen sd_`question' = rowsd(`question'_*_num)
	replace sd_`question' = round(sd_`question', 0.01)
	keep cat1 lab *_`question'
	sort cat1 lab
	*tempfile question
	save `question', replace
	
	restore
}

keep general*_num cat1 lab
egen mean_general = rowmean(general_*_num)
replace mean_general = round(mean_general, 0.01)
egen median_general = rowmedian(general_*_num)
replace median_general = round(median_general, 0.01)
egen sd_general = rowsd(general_*_num)
replace sd_general = round(sd_general, 0.01)
keep cat1 lab *_general
sort cat1 lab

merge 1:1 lab cat1 using func_democ, nogen
merge 1:1 lab cat1 using new_democ, nogen
merge 1:1 lab cat1 using divided_democ, nogen

sort cat1
br cat1 lab *divided_democ



export excel "Table_Appendix.xls", replace

erase func_democ.dta
erase new_democ.dta
erase divided_democ.dta
